package com.example.user.controller.api;

import com.example.common.util.core.controller.BaseController;
import com.example.common.util.core.page.TableDataInfo;
import com.example.common.util.core.resultbody.AjaxResult;
import com.example.model.domain.entity.user.Patient;
import com.example.user.service.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author juzipi
 * @Date 2021/7/20 17:39
 * @Info
 */
@Api(tags = "就诊人管理")
@RestController
@RequestMapping("api/user/patient")
public class PatientApiController extends BaseController {


    @Autowired
    private PatientService patientService;

    /**

     * 查询就诊人列表
     */
    @ApiOperation("查询就诊人列表")
    @GetMapping("/list")
    public AjaxResult patientList()
    {
        List<Patient> list = patientService.selectPatientList();
        return AjaxResult.success(list);
    }

    /**

     * 获取就诊人详细信息
     */
    @ApiOperation("获取就诊人详细信息")
    @GetMapping("get/{id}")
    public AjaxResult getPatient(@PathVariable("id") Long id)
    {
        return AjaxResult.success(patientService.selectPatientById(id));
    }

    /**
     * 新增就诊人
     */
    @ApiOperation("新增就诊人")
    @PostMapping
    public AjaxResult addPatient(@RequestBody Patient patient)
    {
        return toAjax(patientService.insertPatient(patient));
    }

    /**

     * 修改就诊人
     */
    @ApiOperation("修改就诊人")
    @PutMapping
    public AjaxResult editPatient(@RequestBody Patient patient)
    {
        return toAjax(patientService.updatePatient(patient));
    }

    /**

     * 删除就诊人
     */
    @ApiOperation("删除就诊人")
    @DeleteMapping("/{ids}")
    public AjaxResult removePatient(@PathVariable Long[] ids)
    {
        return toAjax(patientService.deletePatientByIds(ids));
    }

}
